import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import path from 'path'
import AutoImport from 'unplugin-auto-import/vite'
import Components from 'unplugin-vue-components/vite'
import { ElementPlusResolver } from 'unplugin-vue-components/resolvers'
import postCssPxToRem from 'postcss-pxtorem'

// https://vitejs.dev/config/
export default defineConfig({
    plugins: [
        vue(),
        AutoImport({
            resolvers: [ElementPlusResolver()]
        }),
        Components({
            resolvers: [ElementPlusResolver()]
        })
    ],
    resolve: {
        // 配置路径别名
        alias: {
            '@': path.resolve(__dirname, './src')
        }
    },
    css: {
        // css预处理器
        preprocessorOptions: {
            scss: {
                // 引入 scss 这样就可以在全局中使用
                // 给导入的路径最后加上 ;
                additionalData: '@import "@/assets/scss/global.scss";'
            }
        },
        postcss: {
            plugins: [
                postCssPxToRem({
                    rootValue: 37,
                    propList: ['*']
                })
            ]
        }
    }
})
